/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author cegarciaa
 */
@Entity
@Table(name = "varbd")
@NamedQueries({
    @NamedQuery(name = "Varbd.findAll", query = "SELECT v FROM Varbd v"),
    @NamedQuery(name = "Varbd.findByDato", query = "SELECT v FROM Varbd v WHERE v.dato = :dato"),
    @NamedQuery(name = "Varbd.findByIddispositivo", query = "SELECT v FROM Varbd v WHERE v.varbdPK.iddispositivo = :iddispositivo"),
    @NamedQuery(name = "Varbd.findByIdvariableb", query = "SELECT v FROM Varbd v WHERE v.varbdPK.idvariableb = :idvariableb")})
public class Varbd implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected VarbdPK varbdPK;
    @Column(name = "DATO")
    private Integer dato;
    @JoinColumn(name = "IDVARIABLEB", referencedColumnName = "IDVARIABLEB", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Variableb variableb;
    @JoinColumn(name = "IDDISPOSITIVO", referencedColumnName = "IDDISPOSITIVO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Dispositivo dispositivo;

    public Varbd() {
    }

    public Varbd(VarbdPK varbdPK) {
        this.varbdPK = varbdPK;
    }

    public Varbd(long iddispositivo, long idvariableb) {
        this.varbdPK = new VarbdPK(iddispositivo, idvariableb);
    }

    public VarbdPK getVarbdPK() {
        return varbdPK;
    }

    public void setVarbdPK(VarbdPK varbdPK) {
        this.varbdPK = varbdPK;
    }

    public Integer getDato() {
        return dato;
    }

    public void setDato(Integer dato) {
        this.dato = dato;
    }

    public Variableb getVariableb() {
        return variableb;
    }

    public void setVariableb(Variableb variableb) {
        this.variableb = variableb;
    }

    public Dispositivo getDispositivo() {
        return dispositivo;
    }

    public void setDispositivo(Dispositivo dispositivo) {
        this.dispositivo = dispositivo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (varbdPK != null ? varbdPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Varbd)) {
            return false;
        }
        Varbd other = (Varbd) object;
        if ((this.varbdPK == null && other.varbdPK != null) || (this.varbdPK != null && !this.varbdPK.equals(other.varbdPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Varbd[varbdPK=" + varbdPK + "]";
    }

}
